package com.xunjie.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.xunjie.domains.Jobs;
import com.xunjie.mapper.JobsMapper;
import com.xunjie.service.JobsService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;

@Slf4j
@Service
@RequiredArgsConstructor
public class JobsServiceImpl implements JobsService {
    private final JobsMapper mapper;

    @Override
    public List<Jobs> selectAll() {
        List<Jobs> jobsList = mapper.selectList(null);
        if(CollectionUtil.isNotEmpty(jobsList)){
            jobsList.forEach(jobs -> {
                log.info("selectAll查询結果：{}",jobs.toString());
            });
        }
        return jobsList;
    }

    @Override
    public Long count() {
        Long count = mapper.selectCount(null);
        log.info("count查询结果：{}",count);
        return count;
    }

    @Override
    public int update(Jobs jobs) {
        if(ObjectUtil.isNull(jobs)){
            return 0;
        }
        int i = mapper.updateById(jobs);
        log.info("update更新结果：{}",i);
        return i;
    }
}
